package org.anupta.game.server.game.packet.account;

import org.anupta.game.entity.entities.Player;
import org.anupta.game.main.Main;
import org.anupta.game.server.game.client.GameClient;
import org.anupta.game.server.game.packet.GamePacket;
import org.anupta.game.utils.others.Config;

public class AccountList extends GamePacket {
	public AccountList(GameClient client) {
		super(client);
		pack();
		doPacket();
	}

	@Override
	public void unpack() {
	}

	@Override
	public void pack() {
		packetOut.append("ALK")
		.append("31536000000")//TODO: SuscribeTime
		.append("|").append(client.getAccount().getPlayers().size());
		for(Player player : client.getAccount().getPlayers().values()){
			if(player.getGameId() == Config.ID){
				packetOut.append(player.toALK());
			}else{
				continue;
			}
		}
	}

	@Override
	public void doPacket() {
		client.send(packetOut.toString());
		Main.out.println(new StringBuilder("AccountList packet sended to : ").append(client.getIp()).toString());
	}
}
